package com.example.test3.controller;


import com.example.test3.dao.UserMapper;
import com.example.test3.entity.User;
import com.example.test3.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
public class myController {

    @Autowired
    private UserService userService;

    // 注意，此处使用的是 GetMapping 注解，该注解的作用类似与
    // @RequestMapping (value="/user/{id}", method= RequestMethod. GET)，@PostMapping 注解同理
    @GetMapping("/user/{id}")
    public User findById(@PathVariable Long id) {
        return this.userService.findOne(id);
    }
}